import React, {memo, useRef} from 'react';

const App = memo(() => {
  // ref 绑定 DOM
  const titleRef = useRef();
  const inputRef = useRef();

  const showTitleDOM = () => {
    console.log(titleRef.current)
    //获取 input 焦点
    inputRef.current.focus();
  }
  return (
      <div>
        <h2 ref={titleRef} className='title'>Hello World</h2>
        <input ref={inputRef} type="text"/>
        <button onClick={showTitleDOM}>查看title的DOM</button>
      </div>
  );
});

export default App;